<?php
$oUsergroups = UsergroupHandler::getUsergroups();
$oUsers = UserHandler::getUsers();
$sUsergroupUsers = $oUsergroups[$_REQUEST['iUsergroup']]->getUsers();
if ($sUsergroupUsers[$_SESSION['rid']] == 'admin')
{
	$bIsAdmin = true; // Just for shortening code, we'll use this a lot.
}
?>

<table class="boxborder" cellspacing="0">
	<tr>
		<td class="boxhandle" colspan="<?php print $bIsAdmin ? '3' : '2' ?>"><?php print msg('Usergroup') ?></td>
	</tr>
	<tr>
		<td class="control small" colspan="<?php print $bIsAdmin ? '3' : '2' ?>">
			<a href="index.php?sView=user-list"><?php print msg('Users') ?></a> | <a href="index.php?sView=usergroup-list"><?php print msg('Usergroups') ?></a> |
		</td>
	</tr>
	<tr>
		<td class="boxbody center small" colspan="<?php print $bIsAdmin ? '3' : '2' ?>"><?php print $oUsergroups[$_REQUEST['iUsergroup']]->sName ?></td>
	</tr>
	<tr>
<?php
if ($bIsAdmin)
{
	?>
		<td class="listtop center"><a href="javascript: showBox('usergroup-adduser', 'iUsergroup=<?php print $_REQUEST['iUsergroup'] ?>');"><img src="images/<?php print $_SESSION['oUserVars']['images'] ?>/user-add.png" border="0"></a></td>
	<?php
}
?>
		<td class="listtop"><?php print msg('Username') ?></td>
		<td class="listtop"><?php print msg('Rights') ?></td>
	</tr>
<?php
foreach ($sUsergroupUsers as $iThisUserID => $sThisAccess)
{
	?>
	<tr>
	<?php
	if ($bIsAdmin)
	{
		print '<td class="listentity center nowrap">';
		if ($iThisUserID != $_SESSION['rid']) {
			?>
			<a href="javascript: showBox('usergroup-deleteuser', 'iUsergroup=<?php print $_REQUEST['iUsergroup'] ?>&iUser=<?php print $iThisUserID ?>');"><img src="images/<?php print $_SESSION['oUserVars']['images'] ?>/user-delete.png" border="0"></a>
			<a href="javascript: showBox('usergroup-changeuser', 'iUsergroup=<?php print $_REQUEST['iUsergroup'] ?>&iUser=<?php print $iThisUserID ?>');"><img src="images/<?php print $_SESSION['oUserVars']['images'] ?>/user-change.png" border="0"></a>
			<?php
		}
		else {
			print '&nbsp;';
		}
		print '</td>';
	}
	?>
		<td class="listentity"><a href="index.php?sView=user-view&iUser=<?php print $iThisUserID ?>"><?php print $oUsers[$iThisUserID]->sUser ?></a></td>
		<td class="listentity"><?php print ($sThisAccess == 'admin' ? msg('Group admin') : msg('User')) ?></td>
	</tr>
	<?php
}
?>
</table>
